﻿using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Layout;

namespace StarWarsSagaCreator
{
    class LabeledTxtBox : Panel
    {
        private Label mylabel;
        private ComboBox mytext;

        public LabeledTxtBox(string labelTxt, string labelName, int tabi)
            : base()
        {
            mylabel = new Label { Text = labelTxt, Name = labelName, TabStop = false, AutoSize = false};
            mylabel.Size = new Size(70, 20);
            mytext = new ComboBox {TabIndex = tabi, AutoSize = false};
            mytext.Size = new Size(110, 20);

            Controls.Add(mylabel);
            Controls.Add(mytext);
        }

        //public LabeledTxtBox()
        //{
        //    new LabeledTxtBox("");
        //}
        //public Label getLabel()
        //{
        //    return mylabel;
        //}

        //public ComboBox getComboBox()
        //{
        //    return mytext;
        //}

        private LayoutEngine _layoutEngine;

        public override LayoutEngine LayoutEngine
        {
            get
            {
                if (_layoutEngine == null) _layoutEngine = new CustomLayoutEngine();
                return _layoutEngine;
            }
        }

        //public override Size GetPreferredSize(Size proposedSize)
        //{
        //    Size size = base.GetPreferredSize(proposedSize);

        //    foreach (Control control in Controls)
        //    {
        //        int newHeight = control.Height + control.Margin.Vertical + Padding.Vertical;
        //        if (newHeight > size.Height) size.Height = newHeight;
        //    }

        //    return size;
        //}
    }
}

